package model

import "fmt"

type GroupInfo struct {
	GroupId   int64  `xorm:"pk notnull authnr 'group_id'"`
	GroupName string `xorm:"notnull 'group_name'"`
}

type UserInfo struct {
	UserId   int64  `xorm:"pk notnull authnr 'user_id'"`
	UserName string `xorm:"notnull 'user_name'"`
	GroupId  int64  `xorm:"index"`
}
type UserGroup struct {
	UserInfo  `xorm:"extends"`
	GroupName string
}

//使用的sql 查询映射到对应结构 上面
func GetUserGroup() {
	re := make([]UserGroup, 0)
	Engine.SQL("SELECT a.*,b.group_name FROM USER_info a,GROUP_info b WHERE a.group_id = b.group_id").Find(&re)
	for i, v := range re {
		fmt.Println(i, v)
	}
}
